//属性列表的接口函数

import request from '@/utils/request'

import type { AttrInfoModel,AttrValueInfoModel,AttrValueListModel  } from '../model/attrModel'

import type { CategoryIdsModel } from './categoryModel'

enum Api{
  // 根据三级导航获取属性列表数据
  getAttrListApi = '/admin/product/attrInfoList',
  // 删除平台属性
  deleteAttrInfoApi = '/admin/product/deleteAttr',
  addOrUpdateAttrInfoApi ='/admin/product/saveAttrInfo'

}

//分类列表数据
export const reqGetAttrListData = ({ category1Id, category2Id, category3Id }: CategoryIdsModel) => {
  return request.get<any,AttrValueInfoModel[]>(Api.getAttrListApi + `/${category1Id}/${category2Id}/${category3Id}`)
}

//删除平台属性
export const reqDeleteAttrInfo = (attrId:number) => {
  return request.delete(Api.deleteAttrInfoApi+`/${attrId}`)
}

//添加或更新属性
export const reqAddOrUpdateAttrInfo = (attrInfo:AttrInfoModel)=>{
  return request.post(Api. addOrUpdateAttrInfoApi,attrInfo)
}